class CtrlMgr {
    public static instance: CtrlMgr = null
    public static getInstance() {
        if (!CtrlMgr.instance) {
            CtrlMgr.instance = new CtrlMgr()
        }
        return CtrlMgr.instance
    }

    private _ctrlList = []

    public addCtrl(ctrl) {
        this._ctrlList.push(ctrl)
    }

    public dispose() {
        this._ctrlList.forEach((ctrl) => {
            ctrl.dispose()
        })
    }

    public newDay() {
        this._ctrlList.forEach((ctrl) => {
            ctrl.newDay()
        })
    }

    public onBackground() {
        this._ctrlList.forEach((ctrl) => {
            ctrl.background()
        })
    }

    public onForeground() {
        this._ctrlList.forEach((ctrl) => {
            ctrl.foreground()
        })
    }

    public init() {
        this._ctrlList.forEach((ctrl) => {
            ctrl.init()
        })
    }
}

export let ctrlMgr = CtrlMgr.getInstance()
